package com.connor.bank.Controller;

import com.connor.bank.Control;

import com.connor.bank.Entity.Login;
import com.connor.bank.Resource.ResourceHandler;
import com.connor.bank.View;

public class LoginControl extends Control{

    private Login login;
    
    public LoginControl(){
        
    }
   
    public LoginControl(String username, char[] password){
        setLogin(username, password);
    }
    
    private void setLogin(String username, char[] password){
        login = new Login(username, String.valueOf(password));
    }

    @Override
    public void actionWith(String userCommand, View view) {
        if(login.validate()){
            ResourceHandler.createProperties("userprofile", login.getUsername());
            mc.actionWith("LoginSuccess", this, view);
        }
        else{
            mc.actionWith("LoginFailed", this, view);
        }
    }
}
